package java1;
import java.util.Random;
import java.util.Scanner;


public class Guess {
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
        Random rand = new Random() ; // 创建一个用于产生随机数的对象
        int score = rand.nextInt( 1000 ) ; // 随机产生一个 [ 0 , 1000 ) 之间的整数
        System.out.print("请猜一个数字：");
        int number = input.nextInt();
        boolean flag = true;
        int count = 0;
        while (flag){
            count++;
            if (number < score) {
                System.out.println("太小了，再大一点！");
                number = input.nextInt();
            }
            else if(number > score){
                System.out.println("太大了，再小一点！");
                number = input.nextInt();
            }
            else{
                System.out.println("恭喜你猜对了！");
                break;
            }

            if(count ==10){
                System.out.println("你太笨了，下次再来吧！");
                break;
            }
        }

    }
}
